﻿// -------------------------------------------------------------------------
//    @FileName         :    NFLifeSkillPart.cpp
//    @Author           :    gaoyi
//    @Date             :    24-8-30
//    @Email            :    445267987@qq.com
//    @Module           :    NFLifeSkillPart
//
// -------------------------------------------------------------------------

#include "NFLifeSkillPart.h"

#include "proto_cs_login.pb.h"
#include "proto_db.pb.h"

NFLifeSkillPart::NFLifeSkillPart()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFLifeSkillPart::~NFLifeSkillPart()
{
}

int NFLifeSkillPart::CreateInit()
{
    return 0;
}

int NFLifeSkillPart::ResumeInit()
{
    return 0;
}

int NFLifeSkillPart::LoadFromDB(const proto_ff::tbRoleDetail *pDBData)
{
    m_stData.FromPb(pDBData->role_play_data().life_skill_data());
    return 0;
}

int NFLifeSkillPart::InitConfig(proto_ff::tbRoleDetail *pDbData, const RoleOne &stRoleOne)
{
    int iRetCode = 0;

    CHECK_NULL(0, pDbData);
    auto pRoleLifeSkillData = pDbData->mutable_role_play_data()->mutable_life_skill_data();
    CHECK_NULL(0, pRoleLifeSkillData);

    pRoleLifeSkillData->clear_role_life_skill_list();
    for (int i = 1; i < proto_ff::EN_LIFE_SKILL_TYPE_MAX; ++i)
    {
        proto_ff::LifeSkillOne *pLifeSkillOne = pRoleLifeSkillData->add_role_life_skill_list();
        pLifeSkillOne->set_exp(0);
        pLifeSkillOne->set_id(proto_ff::enLifeSkillType(i));
        pLifeSkillOne->set_level(0);
        pLifeSkillOne->set_step(0);
        pLifeSkillOne->set_unlock(false);
        pLifeSkillOne->set_step_finish_time(0);
        pLifeSkillOne->set_step_start_time(0);
        pLifeSkillOne->set_today_used_times(0);
        pLifeSkillOne->set_total_used_times(0);
        pLifeSkillOne->set_is_running(false);
        pLifeSkillOne->set_exp(0);
        pLifeSkillOne->set_type(proto_ff::enLifeSkillType(i));
    }

    pRoleLifeSkillData->set_last_update_data_time(NF_ADJUST_TIMENOW_MS());

    return iRetCode;
}

int NFLifeSkillPart::SaveDB(proto_ff::tbRoleDetail *pDBData)
{
    m_stData.ToPb(pDBData->mutable_role_play_data()->mutable_life_skill_data());
    return 0;
}

int NFLifeSkillPart::MakePlayerDataCS(proto_ff::Proto_CSGetRoleRsp* pCSGetRoleRsp)
{
    m_stData.ToPb(pCSGetRoleRsp->mutable_life_skill_data());
    return 0;
}

int NFLifeSkillPart::MakeCityPlayerData(proto_ff::CityRoleInfo* pGCCityRoleInfo)
{
    return 0;
}
